package directory

import (
	"gitlab.local/TerraMaster/tos-modules/core/acl"
	"gitlab.local/TerraMaster/tos-modules/database"
	"gitlab.local/TerraMaster/tos-modules/database/sqlitemodel"
	"gitlab.local/TerraMaster/tos-modules/directory"
)

type FolderQuota struct {
	Path string `json:"path"` //文件夹路径
	Size int    `json:"size"` //单位GB
}

type CreateFolder struct {
	sqlitemodel.Share
	PassPhrase string      `json:"pass_phrase"` //加密文件夹的密码
	Acls       []acl.Attrs `json:"acls"`
}

type ModifyFolder struct {
	sqlitemodel.Share
	OldName string `json:"old_name"` //原来名称
}

type FolderService interface {
	Create(string, directory.CreateFolder) (string, error)
	Get() (result []sqlitemodel.Share)
	GetByType(cate string) (result []sqlitemodel.Share)
	Set(int, directory.ModifyFolder) (string, error)
	Del(int) error
	GetFolder(int) sqlitemodel.Share
	EcryptfsMount(string, string) error
	EcryptfsUmount(string) error
	ObtainSecretKey(string, string) (string, uint8, error)
	FolderIsMount(path string) (bool, error)
}

type Directory struct {
	dbGetter database.DbGetter
}

func New(dbGetter database.DbGetter) *Directory {
	return &Directory{
		dbGetter: dbGetter,
	}
}
